use super::*;
use lexer::*;

// ## 10. Specifying anonymous data blocks
#[derive(Debug, Clone)]
pub struct Anon(pub String);
impl Anon {
	pub fn parse(r: &mut Lexer<'_>) -> Result<Self, Error> {
		let name = r.expect_ident()?;
		r.expect(Event::LBrace)?;
		let v = r.read_anon('}', name)?;
		r.expect(Event::Ident(name))?;
		r.expect(Event::Semi)?;
		Ok(Self(v.into()))
	}
}

#[cfg(test)]
mod tests {
	use super::*;
	#[test]
	fn anon() {
		let content = r#"
anon sbit {
	/* sbit table specifications */
	72  % dpi
	sizes {
		10, 12, 14 source {
			all "Generic/JGeneric"
		}
	}
} sbit;
"#;
		_ = Fea::parse("", &mut Lexer::new(content)).unwrap();
	}
}
